﻿// ===============================================================================
// XCI.Parent 西安交通信息WinForm开发框架 2019 版权所有
// ===============================================================================

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using XCI.Sys.Service;
using XCI.Extensions;
using XCI.Windows;
using XCI.Windows.Helper;

namespace XCI.Sys.Forms
{
    /// <summary>
    /// 系统单个字典管理
    /// </summary>
    [FormCaption("系统单个字典管理")]
    public partial class FrmSingleDicManager : FrmSysBase
    {
        public FrmSingleDicManager()
        {
            InitializeComponent();
        }

        private void FrmDicDetailsManager_Load(object sender, EventArgs e)
        {
            if (ParamData.TryGetValue("code", out string code) && code.IsNotEmpty())
            {
                var entity = DicCategoryService.Instance.SelectByCode(code);
                if (entity != null)
                {
                    dicDetailsManagerControl1.SetDicModel(entity);
                }
                else
                {
                    ShowInvalidCodeMessage();
                }
            }
            else
            {
                ShowInvalidCodeMessage();
            }
        }

        private void ShowInvalidCodeMessage()
        {
            MessageBoxHelper.ShowError("请指定正确的字典编码，参数名：code");
        }
    }
}